<?php
include "../configuration.php";
include "./themes/configuration.php";
function adminlinks(){
        $linkarray = array(
              "Home"                 =>   "./admin.php",
               "Edit Front Page"     => "./editfront.php",
               "Moderate Quotes"    => "./modquotes.php",
               "Delete Quotes"   => "./delquotes.php",
               "Admin User Control"    => "./admuc.php",
               "Logout" => "./logout.php",               
);
			
	foreach($linkarray as $linkname => $linkurl){
    		 echo "<a href=\"$linkurl\"><font color=\"black\">$linkname</font></a> / ";
	}
}

function home(){
        $linkarray = array(
              "Home"                 =>   "../",
);

        foreach($linkarray as $linkname => $linkurl){
                 echo "<a href=\"$linkurl\"><font color=\"black\">$linkname</font></a>";
        }
}

function startsql(){
	global $sqlserver,$sqluser,$sqlpassword,$sqldb;
	$sendmod = mysql_connect($sqlserver,$sqluser,$sqlpassword) or die("Could Not open connection to the Database");
	mysql_select_db($sqldb);
}

function endsql(){
	global $sendmod;
	mysql_close($sendmod);
}

function qheader(){
        echo '<center><img src="./themes/logo.png" alt="Logo"> </center><br>';
}

function footer(){
        startsql();     
        $quoteall = mysql_query("SELECT * FROM quotes");
        $nquote = mysql_num_rows($quoteall);
        
        $queueall = mysql_query("SELECT * FROM queue");
        $nqueue = mysql_num_rows($queueall);
 
        echo "Life To Death Quote Database by Stranded<br>
              $nquote quotes | $nqueue awaiting moderation";
}
function sendadmin($username,$password){
        global $sqlserver,$sqluser,$sqlpassword,$sqldb;
        $sendadmin = mysql_connect($sqlserver,$sqluser,$sqlpassword) or die("Could Not open connection to the Database");
        mysql_select_db($sqldb);
        $username   = mysql_real_escape_string($username);
        $password = mysql_real_escape_string($password);
        $query = mysql_query ("SELECT `username` FROM `members` WHERE `username` = '$username'");
        if (mysql_num_rows ($query) > 0) { echo "Username exists"; 
        return true;
} else {
        mysql_query("INSERT INTO members (ID, username, password) VALUES(NULL, '$username', '$password' ) ") or die(mysql_error());
        mysql_close($sendadmin);

}

}
function inputform2(){
  // Input form for admins
        echo '
<form action="sendadmin.php" method="post">Create a new admin user.<br>
        Username:<input name="username" type="text" value="Username" size="15" maxlength="15"><br>
        Password:<input name="password" type="password" value="Password" size="15" maxlength="15"><br>
        <input type="submit" value="Submit">
</form>
';
}

function css($css) {
        echo '<link href="'. $css .'" rel="stylesheet" type="text/css">';
}

function title($title) { echo $title; }

?>
